package com.twoGroup.boot.utils;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class TeleNumUtils {
    public static Logger logger = LoggerFactory.getLogger(TeleNumUtils.class);

    public boolean TelephoneBool(String telephone){
        return telephone.length()==11 && phone(telephone);
    }

    public static boolean phone(String phone) {
            String regex = "^((13[0-9])|(14[5|7])|(15([0-3]|[5-9]))|(17[013678])|(18[0,5-9]))\\d{8}$";
            Pattern p = Pattern.compile(regex);
            Matcher m = p.matcher(phone);
            boolean isMatch = m.matches();
            if (isMatch) {
                logger.info("您的手机号" + phone + "是正确格式@——@");
                return true;
            } else {
                logger.info("您的手机号" + phone + "是错误格式！！！");
                return false;
            }
        }
}
